<?php

    // update language
    switch ($change_new)
        {
            case 'Deutsch':$sql5= "update settings set learn='Deutsch', learnde='Deutsch', learnen='German', learnes='Alemán', learnru='Немецкий' where customerid = ". $customerid;break;
            case 'Englisch':$sql5= "update settings set learn='Englisch', learnde='Englisch', learnen='English', learnes='Inglés', learnru='Английский' where customerid = ". $customerid;break;
            case 'Spanisch':$sql5= "update settings set learn='Spanisch', learnde='Spanisch', learnen='Spanish', learnes='Español', learnru='Испанский' where customerid = ". $customerid;break;
            case 'Russisch':$sql5= "update settings set learn='Russisch', learnde='Russisch', learnen='Russian', learnes='Ruso', learnru='Русский' where customerid = ". $customerid;
        }

    $db_sel5 = mysql_query_secure( $sql5 );

    // check, if oldlanguage = newlanguage
	$sql7 = " select cande, learnde from settings ";
    $sql7 .= " where customerid = ". $customerid;
    $db_sel7 = mysql_query_secure( $sql7 );

    while ($row = mysql_fetch_array( $db_sel7, MYSQL_ASSOC)) {
	// update internal variables
	$can_lang = $row['cande'];
	$learn_lang = $row['learnde'];
	
    if ( $row['cande'] == $change_new )
    {
        // update language can
	    $sql9 = " update settings set ";
        $sql9 .= " can = '-', cande = '-', canen = '-', canes = '-', canru = '-', langpair = '' ";
        $sql9 .= " where customerid = ". $customerid;
        $db_sel9 = mysql_query_secure( $sql9 );

    }
    elseif ( $row['cande'] == '' or $row['cande'] == '-' ) {}
    else
    {
        //check langpair
  	    $sql14 = " select langpairid from langpairs_german ";
        $sql14 .= " where learn = '". $row['learnde'] . "' and ";
        $sql14 .= " can = '". $row['cande'] . "'";
        $db_sel14 = mysql_query_secure( $sql14 );

        while ($row = mysql_fetch_array( $db_sel14, MYSQL_ASSOC)) {
            $langpair = $row['langpairid'];
        }

        if ( $langpair <> '' ) {
            // update langpair
	        $sql15 = " update settings set ";
            $sql15 .= " langpair = '". $langpair . "' ";
            $sql15 .= " where customerid = ". $customerid;
            $db_sel15 = mysql_query_secure( $sql15 );

        }
	}
}
?>

